package cate.game.pvp.guildwar.data;

import cate.common.table.d.GDGuildWar;
import cate.game.play.part.PlaySide;
import com.fasterxml.jackson.annotation.JsonIgnore;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

@NoteClass("公会战据点")
public class GuildWarPt {

    @NoteField("据点ID")
    public int ptId;

    @NoteField("当前获得的星数")
    public int star;

    @NoteField(value = "防守阵容",detail = "")
    public PlaySide ps;


    public void initialize() {
    }

    public GuildWarPt() {
    }

    @JsonIgnore
    public boolean isRuin() {
        return star >= GDGuildWar.STAR_MAX;
    }

    public int addStar(int add) {
        final int old = this.star;
        this.star += add;
        if (this.star >= GDGuildWar.STAR_MAX) {
            this.star = GDGuildWar.STAR_MAX;
        }
        return star - old;
    }

    public void updateStar(int star) {
        if (this.star > star) {
            return;
        }
        this.star = star;
    }
}
